package com.example.administrator.activity.parcitise.Activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.example.administrator.activity.R;

public class GoddnessActivity extends AppCompatActivity {

    private ImageView image_pi;
    private RadioButton rb_rpi, rb_rgu;
    private RadioGroup rg_imagep;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goddness);

        init();

        final RadioGroup.OnCheckedChangeListener check = new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                /**
                 * checkId 表示点击的是哪个单选按钮
                 */
                switch (checkedId) {
                    case R.id.rpi:
                        image_pi.setImageResource(R.drawable.yinghua);
                        Toast.makeText(GoddnessActivity.this, "皮卡丘+1", Toast.LENGTH_SHORT).show();
                        break;

                    case R.id.rgu:
                        image_pi.setImageResource(R.drawable.bi);
                        Toast.makeText(GoddnessActivity.this, "亚古兽+1", Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        };

        rg_imagep.setOnCheckedChangeListener(check);

    }

    private void init() {
        image_pi = findViewById(R.id.pi);
        rb_rpi = findViewById(R.id.rpi);
        rb_rgu = findViewById(R.id.rgu);
        rg_imagep = findViewById(R.id.imagep);

        image_pi.setImageResource(R.drawable.yinghua);
        rb_rpi.setChecked(true);
    }
}
